﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LambdaAnonimousExtensionMethods
{
    class Program
    {
        static void Main(string[] args)
        {
          //1.  Implement an extension method Substring(int index, int length) for the class StringBuilder that returns new StringBuilder and has the same functionality as Substring in the class String.
            //StringBuilder testBuilder = new StringBuilder("This is an example!");
            //StringBuilder subStringBuilderExample = testBuilder.SubStrinBuilder(5, 7);
            //Console.WriteLine(subStringBuilderExample);

            //List<int> myNums =new List<int> {2,5,7,3,11};
            //List<string> myStrs = new List<string> { "asf", "asfas", "frd" };
            //Console.WriteLine(myNums.SumElements<int>());
            //Console.WriteLine(myNums.ProductElements<int>());
            //Console.WriteLine(myNums.MinElements<int>());
            //Console.WriteLine(myStrs.MinElements<string>());
            //Console.WriteLine(myNums.AvarageElements<int>());

            //Student num1 = new Student("petyr","vasilev",14);
            //Student num2 = new Student("ivan", "vasilev",15);
            //Student num3 = new Student("milen", "stanoev",20);
            //Student num4 = new Student("stoqn", "stoqnov",25);
            //Student num5 = new Student("rosen", "troqnov",20);
            //Student num6 = new Student("go6o", "emilov",30);

            //List<Student> students=new List<Student>();
            //students.Add(num1);
            //students.Add(num2);
            //students.Add(num3);
            //students.Add(num4);
            //students.Add(num5);
            //students.Add(num6);
            //students.GreaterFirst();
            ////foreach (var item in students)
            ////{
            ////    Console.WriteLine(item);
            ////}

            //var resultAge =
            // from student in students
            // where student.Age >= 18 && student.Age <= 26
            // select new { firstName = student.FirstName, lastName=student.LastName};

            ////foreach (var item in resultAge)
            ////{
            ////    Console.WriteLine(item.firstName + " " + item.lastName);
            ////}

            //var sortedFirstName = students.OrderByDescending(student => student.FirstName);
            //foreach (var item in sortedFirstName)
            //{
            //    Console.WriteLine(item.ToString());
            //}

            //var sortedLasttName = students.OrderByDescending(student => student.LastName);
            //foreach (var item in sortedLasttName)
            //{
            //    Console.WriteLine(item.ToString());
            //}

           // List<int> myList = new List<int>() { 2, 3, 4, 6, 1, 14, 2, 16 };
            int[] ints = { 2, 3, 4, 6, 1, 14, 2, 16 };

            //6 Lambda
            //var devisorsOf7And3 = ints.ToList().FindAll((i) =>
            //{
            //    return ((i % 7) == 0) ||((i % 3) == 0) ;
            //});
            //;
            //foreach (var item in devisorsOf7And3)
            //{
            //    Console.WriteLine(item);
            //}

            //7Linq
            var devisorsOf7And3Linq =
                from inte in ints
                where inte % 3 == 0 || inte % 7 == 0
                select inte;

            foreach (var item in devisorsOf7And3Linq)
            {
                Console.WriteLine(item);
            }


            string myStr = "my name is Milen!";
                Console.WriteLine(myStr.UpperFirtsLetter());
        }
    }
}
